﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Model;
using System.Data.SqlClient;
using System.Data;

namespace jdm.exam.dal
{
    public class ExamDal
    {
        SqlConnection conn = new SqlConnection("Data Source=.;Initial Catalog=考试;Integrated Security=True");

        public Usere Login(string U_ID,string U_Pwd)
        {
            conn.Open();
            string sql = "select * from Usere where U_ID='" + U_ID + "' and U_Pwd='" + U_Pwd + "'";
            SqlCommand comm = new SqlCommand(sql, conn);
            SqlDataAdapter adp = new SqlDataAdapter(comm);
            DataTable dt = new DataTable();
            adp.Fill(dt);
             
            Usere m = new Usere();
            m.ID = Convert.ToInt32(dt.Rows[0]["ID"]);
            m.U_ID = dt.Rows[0]["U_ID"].ToString();
            m.U_Pwd = dt.Rows[0]["U_Pwd"].ToString();
            m.U_Name = dt.Rows[0]["U_Name"].ToString();
            m.U_College = dt.Rows[0]["U_College"].ToString();
            m.U_Profess = dt.Rows[0]["U_Profess"].ToString();
            m.U_Phase = dt.Rows[0]["U_Phase"].ToString();
            m.U_Class = dt.Rows[0]["U_Class"].ToString();
            m.U_State = Convert.ToInt32(dt.Rows[0]["U_State"]);
            return m;

        }
    }
}
